<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Sphere - Three.js Docs</title>
	<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<script src="../scripts/highlight.min.js"></script>
	<link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
	<link type="text/css" rel="stylesheet" href="../styles/page.css">
</head>
<body>
	<h1 translate="no">Sphere</h1>
		<section>
			<header>
				<div class="class-description"><p>An analytical 3D sphere defined by a center and radius. This class is mainly
used as a Bounding Sphere for 3D objects.</p></div>
			</header>
			<article>
				<div class="container-overview">
					<h2>Constructor</h2>
					<h3 class="name name-method" id="Sphere" translate="no">new <a href="#Sphere">Sphere</a><span class="signature">( center : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, radius : <span class="param-type">number</span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Constructs a new sphere.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>center</strong>
									</td>
									<td class="description last">
										<p>The center of the sphere</p>
										<p>Default is <code>(0,0,0)</code>.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>radius</strong>
									</td>
									<td class="description last">
										<p>The radius of the sphere.</p>
										<p>Default is <code>-1</code>.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<h2 class="subsection-title">Properties</h2>
				<div class="member">
					<h3 class="name" id="center" translate="no">.<a href="#center">center</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
					<div class="description">
						<p>The center of the sphere</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="isSphere" translate="no">.<a href="#isSphere">isSphere</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
					<div class="description">
						<p>This flag can be used for type testing.</p>
						<p>Default is <code>true</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : number</span> </h3>
					<div class="description">
						<p>The radius of the sphere.</p>
					</div>
				</div>
				<h2 class="subsection-title">Methods</h2>
					<h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Transforms this sphere with the given 4x4 transformation matrix.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>matrix</strong>
									</td>
									<td class="description last">
										<p>The transformation matrix.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="clampPoint" translate="no">.<a href="#clampPoint">clampPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Clamps a point within the sphere. If the point is outside the sphere, it
will clamp it to the closest point on the edge of the sphere. Points
already inside the sphere will not be affected.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>point</strong>
									</td>
									<td class="description last">
										<p>The plane to clamp.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>target</strong>
									</td>
									<td class="description last">
										<p>The target vector that is used to store the method's result.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The clamped point.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns a new sphere with copied values from this instance.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="containsPoint" translate="no">.<a href="#containsPoint">containsPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if this sphere contains the given point inclusive of
the surface of the sphere.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>point</strong>
									</td>
									<td class="description last">
										<p>The point to check.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this sphere contains the given point or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Copies the values of the given sphere to this instance.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>sphere</strong>
									</td>
									<td class="description last">
										<p>The sphere to copy.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="distanceToPoint" translate="no">.<a href="#distanceToPoint">distanceToPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns the closest distance from the boundary of the sphere to the
given point. If the sphere contains the point, the distance will
be negative.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>point</strong>
									</td>
									<td class="description last">
										<p>The point to compute the distance to.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The distance to the point.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if this sphere is equal with the given one.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>sphere</strong>
									</td>
									<td class="description last">
										<p>The sphere to test for equality.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this bounding sphere is equal with the given one.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="expandByPoint" translate="no">.<a href="#expandByPoint">expandByPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Expands the boundaries of this sphere to include the given point.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>point</strong>
									</td>
									<td class="description last">
										<p>The point to include.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="fromJSON" translate="no">.<a href="#fromJSON">fromJSON</a><span class="signature">( json : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns a serialized structure of the bounding sphere.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>json</strong>
									</td>
									<td class="description last">
										<p>The serialized json to set the sphere from.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="getBoundingBox" translate="no">.<a href="#getBoundingBox">getBoundingBox</a><span class="signature">( target : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns a bounding box that encloses this sphere.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>target</strong>
									</td>
									<td class="description last">
										<p>The target box that is used to store the method's result.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> The bounding box that encloses this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="intersectsBox" translate="no">.<a href="#intersectsBox">intersectsBox</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if this sphere intersects with the given box.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>box</strong>
									</td>
									<td class="description last">
										<p>The box to test.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this sphere intersects with the given box or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="intersectsPlane" translate="no">.<a href="#intersectsPlane">intersectsPlane</a><span class="signature">( plane : <span class="param-type"><a href="Plane.html">Plane</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if this sphere intersects with the given plane.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>plane</strong>
									</td>
									<td class="description last">
										<p>The plane to test.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this sphere intersects with the given plane or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="intersectsSphere" translate="no">.<a href="#intersectsSphere">intersectsSphere</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if this sphere intersects with the given one.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>sphere</strong>
									</td>
									<td class="description last">
										<p>The sphere to test.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this sphere intersects with the given one or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="isEmpty" translate="no">.<a href="#isEmpty">isEmpty</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns <code>true</code> if the sphere is empty (the radius set to a negative number).</p>
<p>Spheres with a radius of <code>0</code> contain only their center point and are not
considered to be empty.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Whether this sphere is empty or not.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="makeEmpty" translate="no">.<a href="#makeEmpty">makeEmpty</a><span class="signature">()</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Makes this sphere empty which means in encloses a zero space in 3D.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( center : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, radius : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Sets the sphere's components by copying the given values.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>center</strong>
									</td>
									<td class="description last">
										<p>The center.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>radius</strong>
									</td>
									<td class="description last">
										<p>The radius.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="setFromPoints" translate="no">.<a href="#setFromPoints">setFromPoints</a><span class="signature">( points : <span class="param-type">Array.&lt;<a href="Vector3.html">Vector3</a>></span>, optionalCenter : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Computes the minimum bounding sphere for list of points.
If the optional center point is given, it is used as the sphere's
center. Otherwise, the center of the axis-aligned bounding box
encompassing the points is calculated.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>points</strong>
									</td>
									<td class="description last">
										<p>A list of points in 3D space.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>optionalCenter</strong>
									</td>
									<td class="description last">
										<p>The center of the sphere.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
					<div class="method">
						<div class="description">
							<p>Returns a serialized structure of the bounding sphere.</p>
						</div>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> Serialized structure with fields representing the object state.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( offset : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Translates the sphere's center by the given offset.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>offset</strong>
									</td>
									<td class="description last">
										<p>The offset.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
					<h3 class="name name-method" id="union" translate="no">.<a href="#union">union</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="method">
						<div class="description">
							<p>Expands this sphere to enclose both the original sphere and the given sphere.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>sphere</strong>
									</td>
									<td class="description last">
										<p>The sphere to include.</p>
									</td>
								</tr>
							</tbody>
						</table>
						<dl class="details">
							<dt class="tag-returns"><strong>Returns:</strong> A reference to this sphere.</dt>
						</dl>
					</div>
				<h2 class="subsection-title">Source</h2>
				<p>
					<a href="https://github.com/mrdoob/three.js/blob/master/src/math/Sphere.js" translate="no" target="_blank" rel="noopener">src/math/Sphere.js</a>
				</p>
			</article>
		</section>
<script src="../scripts/linenumber.js"></script>
<script src="../scripts/page.js"></script>
</body>
</html>